package com.ease.web.xwt.component;

/**
 * 
 * @author nathanleewei
 * 
 */
public class XFormPair extends XAbstractComponent {

	/**
	 * 
	 */
	private static final long serialVersionUID = 184714705557417690L;

	public static final int COLSPAN = 1;

	public static final int ROWSPAN = 1;

	public static final String FIELD_STYLE = "x_form_field";

	private int colSpan = COLSPAN;

	private int rowSpan = ROWSPAN;

	private String label;

	private int orderIndex = 0;

	private String labelFor;

	private boolean border;

	private boolean visible = true;

	private boolean notNull = false;

	private boolean disabled = true;

	private String field;

	// private boolean numberOnly = false;

	public XFormPair() {

	}

	public XFormPair(String label, String labelFor, String field, int colSpan, boolean notNull) {
		this.setLabel(label);
		this.setLabelFor(labelFor);
		this.setField(field);
		this.setColSpan(colSpan);
		this.setNotNull(notNull);
	}

	public XFormPair(String label, String labelFor, String field, int colSpan) {
		this(label, labelFor, field, colSpan, false);
	}

	public static String emptyCell(int _colspan) {

		StringBuffer sb = new StringBuffer();
		sb.append("<td class=\"x_form_field\"");
		sb.append((_colspan > 1) ? (" colspan=" + _colspan) : "");
		sb.append(">&nbsp;</td>\r\n");

		return sb.toString();
	}

	protected String getTemplate() {
		return TEMPLATE_X_FORMPAIR;
	}

	public XFormPair(int _colSpan, boolean _border) {
		this.setColSpan(_colSpan);
		this.setBorder(_border);
	}

	/*
	 * public String generate() {
	 * 
	 * return super.generate(); }
	 */

	/*
	 * public String toString(boolean border) { }
	 */

	/**
	 * @return Returns the orderIndex.
	 */
	public int getOrderIndex() {
		return orderIndex;
	}

	/**
	 * @param orderIndex
	 *            The orderIndex to set.
	 */
	public void setOrderIndex(int orderIndex) {
		this.orderIndex = orderIndex;
	}

	/**
	 * @return Returns the border.
	 */
	public boolean isBorder() {
		return border;
	}

	/**
	 * @param border
	 *            The border to set.
	 */
	public void setBorder(boolean border) {
		this.border = border;
	}

	/**
	 * @return Returns the disabled.
	 */
	public boolean isDisabled() {
		return disabled;
	}

	/**
	 * @param disabled
	 *            The disabled to set.
	 */
	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}

	/**
	 * @return Returns the field.
	 */
	public String getField() {
		return field;
	}

	/**
	 * @param field
	 *            The field to set.
	 */
	public void setField(String field) {
		this.field = field;
	}

	/**
	 * @return Returns the label.
	 */
	public String getLabel() {
		return label;
	}

	/**
	 * @param label
	 *            The label to set.
	 */
	public void setLabel(String label) {
		this.label = label;
	}

	/**
	 * @return Returns the labelFor.
	 */
	public String getLabelFor() {
		return labelFor;
	}

	/**
	 * @param labelFor
	 *            The labelFor to set.
	 */
	public void setLabelFor(String labelFor) {
		this.labelFor = labelFor;
	}

	/**
	 * @return Returns the notNull.
	 */
	public boolean isNotNull() {
		return notNull;
	}

	/**
	 * @param notNull
	 *            The notNull to set.
	 */
	public void setNotNull(boolean notNull) {
		this.notNull = notNull;
	}

	/**
	 * @return Returns the visible.
	 */
	public boolean isVisible() {
		return visible;
	}

	/**
	 * @param visible
	 *            The visible to set.
	 */
	public void setVisible(boolean visible) {
		this.visible = visible;
	}

	/**
	 * @return Returns the colSpan.
	 */
	public int getColSpan() {
		return colSpan;
	}

	/**
	 * @param colSpan
	 *            The colSpan to set.
	 */
	public void setColSpan(int colSpan) {
		this.colSpan = colSpan;
	}

	/**
	 * @return Returns the rowSpan.
	 */
	public int getRowSpan() {
		return rowSpan;
	}

	/**
	 * @param rowSpan
	 *            The rowSpan to set.
	 */
	public void setRowSpan(int rowSpan) {
		this.rowSpan = rowSpan;
	}

}
